package cn.smile;

import cn.smile.interceptor.CustomInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 毛苏宇
 * User: me
 * Date: 2021/4/22
 * Time: 12:49
 * Description:
 */
@ComponentScans({@ComponentScan("cn.smile")})
public class Application {

    /**
     * 拦截器
     * @return
     */
    @Bean
    public CustomInterceptor customInterceptor(){
        return new CustomInterceptor();
    }


    /**
     * 上传文件配置
     *
     * @return
     */
    @Bean
    public CommonsMultipartResolver multipartResolver() {
        CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
        //配置编码格式
        commonsMultipartResolver.setDefaultEncoding("UTF-8");
        //最大文件大小
        commonsMultipartResolver.setMaxUploadSize(524288000);
        return commonsMultipartResolver;
    }
}
